package com.wqz.day.day.up.controller;


import com.wqz.day.day.up.common.BaseResult;
import com.wqz.day.day.up.enums.WebDriverQueueEnum;
import com.wqz.day.day.up.service.CreditScoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;

/**
 * 企业信用分图片，根据前端页面通过Selenium渲染成图片
 *
 * @author wuqz
 * @date 2024/2/29
 */
@Controller
@RequestMapping("/creditScore")
public class CreditScoreController {

    @Autowired
    private CreditScoreService creditScoreService;

    /**
     * 对应企查查网站上的企查分的弹出框页面
     * @return
     * @throws IOException
     */
    @GetMapping("/creditScoreDetailHtml")
    public ModelAndView creditScoreDetailHtml(@RequestParam String keyNo) throws Exception {
        return creditScoreService.getCreditScoreDetail(keyNo);
    }


    /**
     * 将html渲染成图片,获取企查分的详情
     * @return
     */
    @GetMapping("/getCreditScoreDetailImg")
    @ResponseBody
    public BaseResult<String> getCreditScoreDetailImg(@RequestParam String keyNo) {
        return BaseResult.success("页面截取成功！", creditScoreService.getCreditScoreDetailImg(keyNo, WebDriverQueueEnum.CREDIT_SCORE_DETAIL, "creditScoreDetailHtml"));
    }

}
